
<div id="main-content"> <!-- Main Content Section with everything -->			
	<!-- Page Head -->						
	<div class="clear"></div> <!-- End .clear -->
	
	<div class="content-box"><!-- Start Content Box -->
		
		<div class="content-box-header">
			
			<h3>
				<?php 
					$str = "主机";
					echo $query?'修改'.$str:'新建'.$str;
				?>
			</h3>					
			<div class="clear"></div>
			
		</div> <!-- End .content-box-header -->
		
		<div class="content-box-content">
			
			<div >
			
				<form action="<?php echo base_url()?>host/execute" method="post">
						<input type='hidden' name='id' value='<?php echo $query?$query['id']:''?>' />
						<input type='hidden' name='uid' value='<?php echo $query?$query['uid']:''?>' />
						<input type='hidden' name='query' value='<?php echo $query?$query['query']:''?>' />
						<p>
							<label>名称：</label>
							<input class="text-input small-input" type="text" name="name" value='<?php echo $query?$query['name']:''?>' />						
						</p>
						<p>
							<label>品牌：</label>
							<input class="text-input small-input" type="text" name="brand" value='<?php echo $query?$query['brand']:''?>' /> 										
						</p>
						<p>
							<label>价格：</label>
							<input class="text-input small-input" type="text" name="price" value='<?php echo $query?$query['price']:''?>' /> 										
						</p>
						<p>
							<label>规格：</label>
							<input class="text-input small-input" type="text" name="condition" value='<?php echo $query?$query['condition']:''?>' /> 										
						</p>
						<p>
							<label>购入时间：</label>
							<input id="datepicker" class="text-input small-input" type="text" name="bought" value='<?php echo $query?date('Y-m-d',$query['bought']):''?>' /> 										
						</p>
						<p>
							<label>备注：</label>
							<textarea class="text-input" wrap='virtual' name="remark" cols="20" rows="15"><?php echo $query?$query['remark']:''?></textarea>								
						</p>
						<?php if ($query): ?>
							<?php if ($query['host_parts']): ?>									
								<table style="width:50%;">
									<thead>
										<tr>
											<th>主机配件：</th>
											<th>&nbsp </th>
											<th>&nbsp </th>
											<th>&nbsp </th>
										</tr>
									<thead>
									<tbody>
										<?php $i=0;foreach($query['host_parts'] as $row):$i++;?>
										<tr>
											<td><?php echo $row['name'];?></td>
											<td><?php echo $row['brand'];?></td>
											<td><?php echo $row['condition'];?></td>
											<td>
												<div class="button unstall">
												卸载入库
												<input type="hidden" value="5_<?php echo $row['id']?>">
												</div>
												<div class="button unstall">
												卸载报废
												<input type="hidden" value="6_<?php echo $row['id']?>">
												</div>
											</td>
										</tr>
										<?php endforeach?>
										<input type="hidden" value='<?php echo $i;?>' name="partscount">
									</tbody>
								</table>
							<?php endif;?>	
						<?php else:?>
						<p>
							<label>个数：</label>
							<input class="text-input" style="width:20px;" name="count" value='1' />
						</p>
						<?php endif;?>
						<p>
							<input class="button" type="submit" value="Submit" />
							<input class="button back" type="button" value="Back" />
						</p>
					<div class="clear"></div><!-- End .clear -->
				</form>						
			</div>					
		</div> <!-- End .content-box-content -->
		
	</div> <!-- End .content-box -->
	<div class="clear"></div>			
</div> <!-- End #main-content -->	

<script>
	$(function() {
		$( "#datepicker" ).datepicker({dateFormat:'yy-mm-dd'});
		$(".unstall").click(function(){
			$(this).parents("tr").addClass("del");
			$.post("<?php echo base_url();?>host/ajax",{data:$(this).children().val()},function(result){
				$(".del").remove();
			});
		});
	});
</script>